package com.wancaijinfu.ui.index1;



import com.wancaijinfu.actitvity.R;
import com.wancaijinfu.constant.Params;
import com.wancaijinfu.constant.Url;
import com.wancaijinfu.javabean.Repayment;
import com.wancaijinfu.javabean.UserData;
import com.wancaijinfu.parse.RepaymentListParse;
import com.wancaijinfu.widget.MActionBar;
import com.wancaijinfu.widget.PullListBaseActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class ProjectRepayActivity extends PullListBaseActivity {
String borrow_id;

	
	@Override
	public void setMTitle(MActionBar actionBar) {
		borrow_id =  (String) getIntent().getSerializableExtra("borrow_id");
			// TODO Auto-generated method stub
			actionBar.setActionBarHideShadow();
			actionBar.setActionBarTitle(getString(R.string.user_info));
	

	}
	
	
	@Override
	public void getUIData() {
		//Map<String, String> params = new HashMap<String, String>();
		Params params = Params.getInstance().add("borrow_id", borrow_id);
		String requestURL = Url.getAddress(Url.REPAYMENTS);
		getNetData(requestURL, params, new RepaymentListParse());
		
			
	}
	
	
	

	@Override
	public View bindViewItem(int position, View convertView, ViewGroup parent,
			Object object) {
		ViewHolder viewHolder = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(this).inflate(
					R.layout.record_item, parent, false);
			viewHolder = new ViewHolder();
			viewHolder.username = (TextView)convertView.findViewById(R.id.username);
			viewHolder.time = (TextView)convertView.findViewById(R.id.time);
			viewHolder.money = (TextView)convertView.findViewById(R.id.money);
			viewHolder.viewtop = convertView.findViewById(R.id.line1);
			viewHolder.viewfoot = convertView.findViewById(R.id.line2);
			
			convertView.setTag(viewHolder);
		} else {	
			viewHolder = (ViewHolder) convertView.getTag();
		}
		final Repayment data = (Repayment) object;
		viewHolder.time.setText(data.repay_time+"");
//		item.id=newObj.getString("id");
//		item.money=newObj.getDouble("money");
//		item.type=newObj.getString("type");
//		item.addtime=newObj.getString("addtime");
		
		
//		viewHolder.time.setText(data.addtime);
		viewHolder.money.setText(data.repayment_account+"");
		viewHolder.username.setText(UserData.getInstance().name);
		if(data.status.equals("-1")){
			viewHolder.viewtop.setVisibility(View.INVISIBLE);
		}else if(data.status.equals("1")){
			viewHolder.viewfoot.setVisibility(View.INVISIBLE);
		}else {
			viewHolder.viewtop.setVisibility(View.VISIBLE);
			viewHolder.viewfoot.setVisibility(View.VISIBLE);
		}
		
		return convertView;
	}
	
	static class ViewHolder {
		public TextView username;
		public TextView money;
		public TextView time;
		public View viewtop;
		public View viewfoot;
	}
	
	

}
